package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-14
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ExpressCompany", description = "快递公司")
public enum ExpressCompany implements BaseEnum {

    /**
     * SF="顺丰速运"
     */
    SF("顺丰速运"),
    /**
     * HTKY="百世快递"
     */
    HTKY("百世快递"),
    /**
     * ZTO="中通快递"
     */
    ZTO("中通快递"),

    STO("申通快递"),
    YTO("圆通速递"),
    YD("韵达速递"),
    YZPY("邮政快递包裹"),
    EMS("EMS"),
    JD("京东快递"),
    UC("优速快递"),
    DBL("德邦快递"),
    ZJS("宅急送"),
    TNT("TNT快递"),
    UNKNOWN("无"),
    ;
    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static ExpressCompany match(String val, ExpressCompany def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ExpressCompany get(String val) {
        return match(val, null);
    }

    public boolean eq(ExpressCompany val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "快递公司", allowableValues = "SF", example = "SF")
    public String getCode() {
        return this.name();
    }

}
